<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>编辑调查</title>
<link href="/include/manage/images/main/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="/include/manage/formbuilder/font-awesome.min.css" />
<link rel="stylesheet" href="/include/manage/formbuilder/formbuilder-min.css" />
  <style>
  * {
    box-sizing: border-box;
  }

  #fb-main {
    background-color: #fff;
    border-radius: 5px;
    min-height: 600px;
  }

  input[type=text] {
    height: 26px;
    margin-bottom: 3px;
  }

  select {
    margin-bottom: 5px;
  }
  </style>
</head>
<body>
<form name="writeform" method="post" action="/manage_survey.ad">
<input type="hidden" name="surveyid" id="surveyid" value="$!surveyDefine.id" />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="30" background="/include/manage/images/main/tab_05.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="12" height="30"><img src="/include/manage/images/main/tab_03.gif" width="12" height="30" /></td>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="46%" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><div align="center"><img src="/include/manage/images/main/tb.gif" width="16" height="16" /></div></td>
                <td width="95%"><span class="STYLE3">当前位置</span>：[互动管理]-[调查管理]</td>
              </tr>
            </table></td>
            <td width="54%"><table border="0" align="right" cellpadding="0" cellspacing="0">
              <tr>
                <td width="60"><table width="90%" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td><a href="/manage_survey.ad?parameter=add&pid=$!surveyDefine.id"><img src="/include/manage/images/main/22.gif" width="14" height="14" /></a></td>
                    <td><a href="/manage_survey.ad?parameter=add&pid=$!surveyDefine.id">新增</a></td>
                  </tr>
                </table></td>
                <td width="52"><table width="88%" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td><a href="/manage_survey.ad?parameter=delete&id=$!surveyDefine.id"><img src="/include/manage/images/main/11.gif" width="14" height="14" /></a></td>
                    <td><a href="/manage_survey.ad?parameter=delete&id=$!surveyDefine.id">删除</a></td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
        <td width="16"><img src="/include/manage/images/main/tab_07.gif" width="16" height="30" /></td>
      </tr>
    </table></td>
  </tr>
  <tr>
  	<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="8" background="/include/manage/images/main/tab_12.gif">&nbsp;</td>
        <td>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#b5d6e6">
    <tr> 
      <td width="320" height="25" bgcolor="#ffffff">&nbsp;调查名称：</td>
      <td bgcolor="#ffffff">&nbsp;
      	<input id="sname" name="sname" type="text" #if($surveyDefine.name) value="$!surveyDefine.name"#else value="未命名"#end onfocus="if(this.value=='未命名')this.value=''" onblur="if(this.value==''){this.value='未命名';}else{saveSurvey();}" />
      </td>
    </tr>
	<tr>
		<td bgcolor="#ffffff" colspan="2">
			<div style="position:relative;">
				<div id="fb-main"></div>
			</div>
		</td>
	</tr>
</table>
		</td>
        <td width="8" background="/include/manage/images/main/tab_15.gif">&nbsp;</td>
      </tr>
    </table></td>
    </tr>
  <tr>
    <td height="35" background="/include/manage/images/main/tab_19.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="12" height="35"><img src="/include/manage/images/main/tab_18.gif" width="12" height="35" /></td>
        <td valign="top"></td>
        <td width="16"><img src="/include/manage/images/main/tab_20.gif" width="16" height="35" /></td>
      </tr>
    </table>
	</td>
  </tr>
</table>
  </form>
<script language="javascript" src="/include/manage/js/jquery.js"></script>
<script language="javascript" src="/include/manage/js/jquery-ui.js"></script>
<script language="javascript" src="/include/manage/formbuilder/index.js"></script>
<script language="javascript" src="/include/manage/formbuilder/underscore-min.js"></script>
<script language="javascript" src="/include/manage/formbuilder/underscore.mixin.deepExtend.js"></script>
<script language="javascript" src="/include/manage/formbuilder/rivets.min.js"></script>
<script language="javascript" src="/include/manage/formbuilder/backbone-min.js"></script>
<script language="javascript" src="/include/manage/formbuilder/deep-model.min.js"></script>
<script language="javascript" src="/include/manage/formbuilder/formbuilder-min.js"></script>
  <script language="javascript">
    $(function(){
      fb = new Formbuilder('#fb-main', {
        bootstrapData: [
			$!surveyDefine.xml
		]
      });

      fb.on('save', function(payload){
        //console.log(payload);
		saveSurvey(payload);
      })
    });
	
	function saveSurvey(){
		var str='{"fields":[$!surveyDefine.xml]}';
		saveSurvey(str);
	}
	
	function saveSurvey(payload){
		$.post('/manage_survey.ad?parameter=ajaxSave',{id:$('#surveyid').val(),name:$('#sname').val(),xml:payload},function(data){
			$('#surveyid').val(data);
		});
	}
  </script>
</body>
</html>